#!/bin/bash

#获取传入的参数
echo "arg:$1"

#获取正在运行的jar包pid
pid=`ps -ef | grep sing | grep 'java -jar' | awk '{print $2}'`

echo "pid:$pid"

#如果pid为空，提示一下，否则执行kill命令
#使用-z做空值判断
if [ -z $pid ];
    then
        echo "$appname not started"
    else
        kill -9 $pid
        echo "$appname stopping..."

check=`ps -ef | grep -w $pid | grep java | awk '{print $2}'`
sleep 5s
echo "check:$pid"
if [ -z $check ];
        then
            echo "$appname pid:$pid was stopped"
        else
            echo "$appname pid:$pid stop failed"
fi
fi